/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import IBO.IClientParticulier;
import IBO.IClientSociete;
import IBO.ITechnicien;
import IUSECASE.IUC_Factory;
import boerrors.ClientInexistantException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author loo
 */
public class Test {
    
    public static void main(String args[]) {
        try {
            IUC_Factory factory = null;
            factory = (IUC_Factory) Naming.lookup("rmi://localhost:1099/factory");
            Vector<ITechnicien> techniciens = factory.getGestionEmployes().listerTechniciens();
            //request.setAttribute("techniciens", techniciens);
            System.out.println("DEbug:");



            ITechnicien tech = null;
            for (int i = 0; i < techniciens.size(); i++) {
                if (345 == techniciens.get(i).getMatricule()) {
                    tech = techniciens.get(i);
                }
            }

            if (tech != null) {
//                    page.println("<body>");
//                    page.println("Bonjour" + " " +tech.getNom());
                //chargement des clients des interventions
                Vector<IClientSociete> listeClientSociete = new Vector<IClientSociete>();
                Vector<IClientParticulier> listeParticulier = new Vector<IClientParticulier>();
                for (int i = 0; i < tech.getListeIInterventionsToday().size(); i++) {
                    int id = tech.getListeIInterventionsToday().get(i).getIClient().getIdClient();
                    Vector<IClientSociete> clientS = factory.getGestionClients().rechercherClientSociete_NumClient(id);
                    if (clientS.size() > 0) {
                        
                        if (!listeClientSociete.contains(clientS.get(0))) {
                            System.out.println(clientS.get(0).getIdClient());
                            listeClientSociete.add(clientS.get(0));
                        }
                    } else {

                        Vector<IClientParticulier> clientP = factory.getGestionClients().rechercherClientParticulier_NumClient(id);
                        System.out.println("test" + listeParticulier.contains(clientP.get(0)));
                        if (!listeParticulier.equals(clientP.get(0))) {           
                            System.out.println(clientP.get(0).getIdClient());
                            listeParticulier.add(clientP.get(0));
                        }
                    }
                }
            }
        } catch (ClientInexistantException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
            

}
